package org.cyz.tools.common.util;

import java.io.*;
import java.util.Properties;

/**
 * @author abccy
 * @title: PropertiesUtil
 * @projectName RedisGUI
 * @description: TODO
 * @date 2020-8-1914:53
 */
public class PropertiesUtil  {

    /**
     * 获取指定的值
     * @param path
     * @param key
     * @return
     */
    public static String getValue(String path,String key) throws Exception{
            FileReader fileReader=new FileReader(path);
            BufferedReader bufferedReader=new BufferedReader(fileReader);
            String line="";
            while ((line=bufferedReader.readLine())!=null) {
                if((null!=line.trim()&&line.trim().length()>0)){
                    if("#".equalsIgnoreCase(line.substring(0,1))){
                        continue;
                    }
                    if(key.equalsIgnoreCase(line.split(" ")[0])){
                        return line.split(" ")[1];
                    }
                }
            }
        return null;
    }
}
